#!/bin/bash

binDir=wzgames/bin

function stop() {
  # shellcheck disable=SC2009
  # shellcheck disable=SC2006
  p=`ps -ef | grep "$binDir"/"$1" |grep -v 'grep'|awk '{print $2}'`
  if [ "$p" ]
  then
      echo "kill $1 pid $p"
      #kill -9 "$p"
      kill "$p"
  else
    echo "not found $binDir/$1 running"
  fi
}

function usage() {
  echo "Usage: $0 {api|uc|cat|g8|aviator|avtower|betower|roubig|routower|admin}"
  exit 1
}

if [ $# -eq 0 ]; then
  usage
fi

case "$1" in
    api|uc|cat|g8|aviator|avtower|betower|roubig|routower|admin)
        stop "$1"
        ;;
    *)
    usage
esac